import java.awt.Font
import java.awt.Color
import com.octo.captcha.service.multitype.GenericManageableCaptchaService
import com.octo.captcha.engine.GenericCaptchaEngine
import com.octo.captcha.image.gimpy.GimpyFactory
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage
import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator
import com.octo.captcha.component.image.backgroundgenerator.GradientBackgroundGenerator
import com.octo.captcha.component.image.color.SingleColorGenerator
import com.octo.captcha.component.image.textpaster.NonLinearTextPaster
// locations to search for config files that get merged into the main config
// config files can either be Java properties files or ConfigSlurper scripts

// grails.config.locations = [ "classpath:${appName}-config.properties",
//                             "classpath:${appName}-config.groovy",
//                             "file:${userHome}/.grails/${appName}-config.properties",
//                             "file:${userHome}/.grails/${appName}-config.groovy"]

// if(System.properties["${appName}.config.location"]) {
//    grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.use.accept.header = false
grails.mime.types = [html: ['text/html', 'application/xhtml+xml'],
        xml: ['text/xml', 'application/xml'],
        text: 'text/plain',
        js: 'text/javascript',
        rss: 'application/rss+xml',
        atom: 'application/atom+xml',
        css: 'text/css',
        csv: 'text/csv',
        all: '*/*',
        json: ['application/json', 'text/json'],
        form: 'application/x-www-form-urlencoded',
        multipartForm: 'multipart/form-data'
]
// The default codec used to encode data with ${}
grails.views.default.codec = "none" // none, html, base64
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
// enable Sitemesh preprocessing of GSP pages
grails.views.gsp.sitemesh.preprocess = true
// scaffolding templates configuration
grails.scaffolding.templates.domainSuffix = 'Instance'

// Set to false to use the new Grails 1.2 JSONBuilder in the render method
grails.json.legacy.builder = false
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true
// whether to install the java.util.logging bridge for sl4j. Disable fo AppEngine!
grails.logging.jul.usebridge = true
// packages to include in Spring bean scanning
grails.spring.bean.packages = []

// set per-environment serverURL stem for creating absolute links
environments {
  production {
    grails.serverURL = "http://www.changeme.com"
  }
  development {
    grails.serverURL = "http://localhost:8080/${appName}"
  }
  test {
    grails.serverURL = "http://localhost:8080/${appName}"
  }

}

// log4j configuration
log4j = {
  // Example of changing the log pattern for the default console
  // appender:
  //
  //appenders {
  //    console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
  //}


  error 'org.codehaus.groovy.grails.web.servlet',  //  controllers
          'org.codehaus.groovy.grails.web.pages', //  GSP
          'org.codehaus.groovy.grails.web.sitemesh', //  layouts
          'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
          'org.codehaus.groovy.grails.web.mapping', // URL mapping
          'org.codehaus.groovy.grails.commons', // core / classloading
          'org.codehaus.groovy.grails.plugins', // plugins
          'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
          'org.springframework',
          'org.hibernate',
          'net.sf.ehcache.hibernate'

  warn 'org.mortbay.log'
}

//验证码模块配置

//注册验证码配置
jcaptchas {
  loginImageCaptcha = new GenericManageableCaptchaService(
          new GenericCaptchaEngine(
                  new GimpyFactory(
                          new RandomWordGenerator(
                                  "abcdefghijklmnopqrstuvwxyz1234567890"
                          ),
                          new ComposedWordToImage(
                                  new RandomFontGenerator(
                                          20, // min font size
                                          30, // max font size
                                          [new Font("Arial", 0, 10)] as Font[]
                                  ),
                                  new GradientBackgroundGenerator(
                                          100, // width
                                          35, // height
                                          new SingleColorGenerator(new Color(74, 145, 199)),
                                          new SingleColorGenerator(new Color(74, 145, 199))
                                  ),
                                  new NonLinearTextPaster(
                                          4, // minimal length of text
                                          4, // maximal length of text
                                          new Color(255, 255, 255)
                                  )
                          )
                  )
          ),
          180, // minGuarantedStorageDelayInSeconds
          180000 // maxCaptchaStoreSize
  )
}
//后台管理员权限配置
//<gd:isPermit roles="ARCHIVES_ADD" info="true"> </gd:isPermit>
cms.admin.roles =
  [
          "超级管理员权限": 0,
          "超级管理员": "SYSTEM_ADMIN",
          "普通权限": 0,
          "栏目管理": "SYSTEM_ARCTYPE",
          "文章管理": "SYSTEM_ARTICLE",
          "留言管理": "SYSTEM_GUESTBOOK",
          "评论管理": "SYSTEM_COMMENT",
          "招聘管理": "SYSTEM_PLACE",
          "页面管理": "SYSTEM_PAGE",
          "短信管理": 0,
          "短信发送": "SYSTEM_SMSSEND",
          "短信记录": "SYSTEM_SMSRECORD",
          "短信充值": "SYSTEM_SMSPRESSURE"
]


ckeditor {
  config = "/js/edit-config-min.js"
  upload {
    //basedir = "/tmp/storagearea/"
    //  baseurl = "/uploads/"
    overwrite = false
    link {
      browser = true
      upload = true
      allowed = ['doc', 'docx', 'flv', 'xls']
      denied = ['html', 'htm', 'php', 'php2', 'php3', 'php4', 'php5',
              'phtml', 'pwml', 'inc', 'asp', 'aspx', 'ascx', 'jsp',
              'cfm', 'cfc', 'pl', 'bat', 'exe', 'com', 'dll', 'vbs', 'js', 'reg',
              'cgi', 'htaccess', 'asis', 'sh', 'shtml', 'shtm', 'phtm']
    }
    image {
      browser = true
      upload = true
      allowed = ['jpg', 'gif', 'jpeg', 'png']
      denied = []
    }
    flash {
      browser = true
      upload = true
      allowed = ['swf']
      denied = []
    }
    flv {
      browser = true
      upload = true
      allowed = ['flv']
      denied = []
    }

  }
}